import { RouteRecordRaw } from 'vue-router';
import { Layout } from '@/router/constant';
import { MonitorOutlined } from '@vicons/antd';
import { renderIcon } from '@/utils/index';
const IFrame = () => import('@/views/iframe/index.vue');
import { useGlobSetting } from "@/hooks/setting";

const setting = useGlobSetting()

/**
 * @param name 路由名称, 必须设置,且不能重名
 * @param meta 路由元信息（路由附带扩展信息）
 * @param redirect 重定向地址, 访问这个路由时,自定进行重定向
 * @param meta.disabled 禁用整个菜单
 * @param meta.title 菜单名称
 * @param meta.icon 菜单图标
 * @param meta.keepAlive 缓存该路由
 * @param meta.sort 排序越小越排前
 *
 * */
const routes: Array<RouteRecordRaw> = [
  {
    path: '/monitor',
    name: 'monitor',
    redirect: '/monitor/server',
    component: Layout,
    meta: {
      title: '系统监控',
      icon: renderIcon(MonitorOutlined),
      permissions: ['system:monitor'],
      sort: 2,
    },
    children: [
      {
        path: 'online',
        name: 'monitor_online',
        meta: {
          title: '在线用户',
          permissions: ['system:monitor:online'],
        },
        component: () => import('@/views/monitor/online/online.vue'),
      },
      {
        path: 'server',
        name: 'monitor_server',
        meta: {
          title: '服务监控',
          permissions: ['system:monitor:server'],
        },
        component: () => import('@/views/monitor/server/server.vue'),
      },
      {
        path: 'druid',
        name: 'monitor_druid',
        meta: {
          title: '数据监控',
          permissions: ['system:monitor:druid'],
          frameSrc: `${setting.urlPrefix}/druid/login.html`,
        },
        component: IFrame,
      },
    ],
  },
];

export default routes;
